package sunwin.yoms.service.publicty;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sunwin.yoms.comm.YomsException;
import sunwin.yoms.dao.VerifyStateDao;
import sunwin.yoms.domain.publicty.VerifyStateDomain;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by watson on 2015/7/28.
 */
@Service
public class VerifyStateService {
    @Autowired
    private VerifyStateDao verifyStateDao;

    public List<VerifyStateDomain> getVerfiDomain(VerifyStateDomain verifyStateDomain) {
        List<VerifyStateDomain> verifyStateDomains = new ArrayList<VerifyStateDomain>();
        verifyStateDomains = verifyStateDao.getDomainCollection(verifyStateDomain);
        return verifyStateDomains;
    }

    //通过id查询
    public VerifyStateDomain getVerifyDomainById(int verifyStateId) {
        return verifyStateDao.getDomainById(verifyStateId);
    }

    //增加
    public void addVerifyDomain(VerifyStateDomain verifyStateDomain) throws YomsException {
        if (verifyStateDao.addDomain(verifyStateDomain) != 1) {
            throw new YomsException("增加审核失败");
        }
    }

    //删除
    public void deleteVerifyDomain(VerifyStateDomain verifyStateDomain) throws YomsException {
        if (verifyStateDao.deleteDomain(verifyStateDomain) != 1) {
            throw new YomsException("删除审核失败");
        }
    }

    //修改
    public void upVerifyDomain(VerifyStateDomain verifyStateDomain) throws YomsException {
        if (verifyStateDao.updateDomain(verifyStateDomain) != 1) {
            throw new YomsException("修改审核是失败");
        }
    }

    //总数量
    public int getCountDomain() {
        return verifyStateDao.getDomainCount();
    }

}
